<template>
<div>
<!--     <van-field v-model="text" label="物品用途" />
    <van-field v-model="tel" type="text" label="未完成工作" />
    <van-field v-model="digit" type="text" label="物品名称" />
    <van-field v-model="digit" type="text" label="数量" />-->
  <van-nav-bar
    title="日报"
    left-text="返回"
    left-arrow
    @click-left="onClickLeft"
  />
  <van-form @submit="onSubmit">
    <van-field
      v-model="data.workDown"
      label="今日完成工作"
      placeholder="请输入"
      :rules="[{ required: true, message: '今日完成工作' }]"
    />
    <van-field
      v-model="data.workLeft"
      label="未完成工作"
      placeholder="请输入"
      :rules="[{ required: true, message: '未完成工作' }]"
    />  <van-field
      v-model="data.workRemark"
      label="备注"
      placeholder="请输入"
      :rules="[{ required: true, message: '备注' }]"
    />
    <div style="margin: 16px;">
      <van-button round block type="info" native-type="submit">
        提交
      </van-button>
    </div>
  </van-form>

</div>
</template>

<script>
  import {Toast} from "vant";
  import worksReport from "@/api/worksReport";
  export default {
    data() {
      return {
        data:{
          workDown:'',//完成内容
          workLeft: '',//未完成工作
          workRemark: '',//备注
        },
      };
    },
    created() {
    },
    methods: {
      /**
       * 提交
       */
      onSubmit(){
        console.log(this.$store.getters.userInfo)
        Toast.loading({
          message: '提交中...',
          forbidClick: true,
        });
        worksReport.saveReport({
          workReportType: 1,//汇报类型（1：日报，2：周报，3：月报）
          userId:this.$store.getters.userInfo.userId,
          deptId:this.$store.getters.userInfo.deptId,
          workDown: this.data.workDown,//完成内容
          workLeft: this.data.workLeft,//未完成工作
          workRemark: this.data.workRemark,//备注
        })
          .then(res => {
            // 返回数据
            Toast.success('提交成功');
            this.data.workDown = '';
            this.data.workLeft = '';
             this.data.workRemark = '';
          })
          .catch(err => {
            // 异常情况
          })

      },
      onClickLeft() {
        this.$router.push('/work')
      },
    }
  }
</script>

<style scoped>

</style>
